<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<fieldset class="layui-elem-field layui-field-title site-title">
		<legend>
			<a name="fixbar" style="font-size: 16px; color: #ce2424;">学员课程成绩</a>
		</legend>
	</fieldset>
	<form class="layui-form" id="myForm" method="post"
		lay-filter="stuform">
		<div class="layui-form-item">
			<div class="layui-inline" style="width: 420px;">
				<label class="layui-form-label">课程名称：</label>
				<div class="layui-input-block">
					<select id="kcid" lay-filter="kcselect" lay-verify="required"
						lay-search>
						<c:forEach var="d" items="${data}">
							<option value="${d.id }">${d.courseName}</option>
						</c:forEach>
					</select>
				</div>
			</div>
		</div>
	</form>
	<table id="exam" lay-filter="exam"></table>
	<script type="text/javascript">
		layui.use('form', function() {
			var form = layui.form;
			form.render('select');

			form.on('select(kcselect)', function(data) {
				var kcuuid = data.value;
				layui.use('table', function() {
					var table = layui.table;
					table.reload('idTest', {
						url : 'kcExamination/page',
						where : {
							kcuuid : kcuuid
						}
						,page: {
						    curr: 1 //重新从第 1 页开始
						  }
					});
				});
			});
		});
		layui.use('table', function() {
			var kcid = $("#kcid").val();
			var table = layui.table;
			table.render({
				elem : '#exam',
				url : 'kcExamination/page',
				title : "学员考核",
				id : 'idTest',
				where:{kcuuid:kcid},
				//toolbar : '#toolbarDemo',
				cols : [ [ {
					field : 'student',
					title : '学员',
					templet : function(d) {
						return d.student ? d.student.name : '';
					}
				}, {
					field : 'banji',
					title : '班级'
				}, {
					field : 'score',
					title : '分数（百分制）',
					edit : 'text'
				} ] ],
				page : true
			});

			table.on('rowDouble',function(obj){
			});
			
			table.on('edit(exam)', function(obj){
				  var id = obj.data.id;
				  var vaule = obj.value;
				  $.post('kcExamination/tijiao',{id:id,vaule:vaule},function(msg){
					  layer.msg(msg);
					  var kcuuid = $("#kcid").val();
					  table.reload('idTest', {
							url : 'kcExamination/page',
							where : {
								kcuuid : kcuuid
							}
						});
				  })
				});

			//监听表头工具事件

			/* table.on('toolbar(assess_table)', function(obj) {
				var checkStatus = table.checkStatus(obj.config.id);
				if (obj.event === "search") {
					layer.open({
						type : 2,
						shade : false,
						shadeClose : true,
						anim : 5,
						content : 'studentAssess/search',
						area : [ '550px', '330px' ],
					});
				}
			}); */

			/* table.on('tool(assess_table)', function(obj) {
				var data = obj.data;
				if (obj.event === "details") {
					layer.open({
						type : 2,
						shade : 0.3,
						shadeClose : true,
						anim : 5,
						content : 'studentAssess/details?id=' + data.id,
						area : [ '550px', '330px' ],
						end: function(){
							table.reload('idTest', {
								  url: 'studentAssess/page'
								});
						}
					});
				}
			}); */
		});
	</script>
</body>
</html>